#pragma execution_character_set("utf-8")

#include <QCoreApplication>
#include <QApplication>
#include <QDebug>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <qstringlist.h>
#include <map>
#include <string>
#include "wireless_system.h"
#include "saver.h"
#include "time_capture.h"
#include "user_config.h"
#include "node_data.h"
#include "node_group.h"
#include "SerialLineIP.hpp"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

	user_config.getParam();
	node_group.updateAllnodesData(user_config.begin_date, user_config.end_date);

	wireless_system* main_win_ptr = new wireless_system;
	main_win_ptr->show();

    return a.exec();
}
//
//
//int main()
//{
//	std::vector<std::pair<int, int>> water;
//	water.clear();
//	water.push_back(std::pair<int, int>(1, 2));
//	water.push_back(std::pair<int, int>(2, 4));
//	water.push_back(std::pair<int, int>(3, 6));
//	water.push_back(std::pair<int, int>(4, 1));
//	water.push_back(std::pair<int, int>(5, 6));
//	water.push_back(std::pair<int, int>(6, 4));
//
//	//node_group.SortPairVec_Sec(water);
//
//	for (std::vector<std::pair<int, int>>::iterator iter = water.begin(); iter != water.end(); iter++)
//	{
//		qDebug() << iter->first << iter->second;
//	}
//	water.clear();
//	water.push_back(std::pair<int, int>(5, 6));
//	water.push_back(std::pair<int, int>(7, 8));
//	qDebug() << "------------------------";
//	for (std::vector<std::pair<int, int>>::iterator iter = water.begin(); iter != water.end(); iter++)
//	{
//		qDebug() << iter->first << iter->second;
//	}
//	return 0;
//}
//
//int main()
//{
//	std::map<int, int> water;
//	water.insert(std::map<int, int>::value_type(3, 1));
//	water.insert(std::map<int, int>::value_type(5, 2));
//	water.insert(std::map<int, int>::value_type(0, 3));
//	water.insert(std::map<int, int>::value_type(12, 4));
//	water.insert(std::map<int, int>::value_type(7, 5));
//	water.insert(std::map<int, int>::value_type(3, 6));
//	for (std::map<int, int>::iterator iter = water.begin(); iter != water.end(); iter++)
//	{
//		qDebug() << iter->first << iter->second;
//	}
//	return 0;
//}
//int main(int argc, char *argv[])
//{
//	user_config.getParam();
//	user_config.update_stamp = NowStamp();
//	user_config.updateEndDate();
//	user_config.saveParam();
//	node_group.updateAllnodesData(user_config.begin_date, user_config.end_date);
//
//	return 0;
//}
//
//int main(int argc, char *argv[])
//{
//	dateData begin_date, end_date;
//	begin_date.Year = 2019;
//	begin_date.Month = 1;
//	begin_date.Day = 1;
//	end_date.Year = 2040;
//	end_date.Month = 12;
//	end_date.Day = 30;
//	node_group.delectAllnodesData(begin_date, end_date);
//
//	return 0;
//}

//int main()
//{
//	uint32_t raw_data = 0x0000421;
//	uint32_t stamp;
//	uint8_t id;
//	bool statue;
//	qDebug() << "raw_data:" << raw_data;
//	stamp = raw_data >> 8;
//	id = (raw_data - (stamp << 8)) >> 1;
//	statue = (raw_data % 2);
//	qDebug() << "stamp:" << stamp;
//	qDebug() << "id:" << id;
//	qDebug() << "statue:" << statue;
//	return 0;
//}

//int main()
//{
//	dateData beginDate, endData;
//	beginDate.Year = 2019;
//	beginDate.Month = 1;
//	endData.Year = 2020;
//	endData.Month = 9;
//	node_group.delectAllnodesData(beginDate, endData);
//	return 0;
//}

//int main()
//{
//	NodeData node_water(1);
//	DayData timeList;
//	for (int i = 0; i < 8; i++)
//	{
//		HourMin time{ i * 3, 40 };
//		time.PowerON = (i % 2);
//		timeList.push_back(time);
//	}
//	(timeList.end() - 1)->PowerON = (timeList.end() - 2)->PowerON;
//	node_water.pushBackDay(timeList, NowYearInt(), NowMonthInt(), NowDayInt());
//	node_water.pushBackDay(timeList, NowYearInt(), NowMonthInt()-1, NowDayInt());
//	///*for (int i = 0; i < timeList.size(); i++)
//	//{
//	//	qDebug() << timeList[i].hour << "\t" << timeList[i].minute << "\t" << timeList[i].PowerON;
//	//}*/
//	/*dateData beginDate = NowDate();
//	beginDate.Month-=2;
//	dateData endDaate = NowDate();
//	endDaate.Month;
//	node_water.updateData(beginDate, endDaate);
//	node_water.qDebugHisData();*/
//	node_water.saveNodeHisData();
//	return 0;
//}

